package com.example.zaq.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author 阿恩
 * @date 2021/3/916:38
 *
 *
 *
 * 20210309    zaq    配置AppConfig
 * 20210315    zaq    修改allowedOrigins："*"改为"http://localhost:8080", "null"
 */

@Configuration
public class AppConfig implements WebMvcConfigurer{
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOrigins("http://localhost:8080", "null")
                .allowedMethods("POST", "GET", "PUT", "OPTIONS", "DELETE")
                .maxAge(3600)
                .allowCredentials(true)
                .allowedHeaders("*");
    }
}
